 //1.公用样式
 require('../../assets/css/index.js')
 //当前页面样式
 require('./addMotiaon.less')

//2.公用js
let dom=require('../../utils/dom.js');
let uti=require('../../utils/utils.js');
let https=require('../../utils/https.js');
let local=require('../../utils/local');
//3.当前页面效果
dom.ready(function(){
    let vla=dom.getById('#text');  
    let but=dom.getById('#but');  
    let imgs=dom.getById('.imgs'); 
    vla.addEventListener('input',function(){
    let num=vla.value
    dom.getById('.countnum').innerText=num.length;
    })
    but.addEventListener('click',function(){
        inp.click()
    })
    inp.addEventListener('change',function(){
        let haha=this.files[0];
        https.imgss(haha,function(res){
            console.log(res);  
        let upimg=document.createElement('img');
        upimg.src=https.BASE_URL+res;
        imgs.appendChild(upimg)  
        })
     })
    cancel.addEventListener('click',function(){
        location.href='./DynamicList.html'
    });
    let en;
    cityone.addEventListener('click',function(){
        https.get('/api/shared/province',function(val){
            en=val.errno
            let pdata=val.data.map(function(v,i){
                let data={
                    label:v.name,
                    value: v.id
                }
                return data;
            })
            weui.picker(pdata, {
                onConfirm: function (result) {
                    local.set('name',result[0]);
                    cityonetxt.innerText=(local.get('name')).label;  
                },
                title: '请选择省份'
            });
        })
    });
    cityone.addEventListener('change',function(){
        console.log(111);
        
        citytwotxt.innerText='请选择所在城市';
    })

    citytwo.addEventListener('click',function(){
       if(en==0){
        https.get('/api/shared/city?provinceId='+(local.get('name')).value,function(val){
            let pdata=val.data.map(function(v,i){
                let data={
                    label:v.name,
                    value: v.id
                }
                return data;
            })
            weui.picker(pdata, {
                onConfirm: function (result) {
                    local.set('name2',result[0]);
                    citytwotxt.innerText=(local.get('name2')).label;  
                },
                title: '请选择城市'
            });
        })
       }  
    })



})